﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Com.DA;
using Com.BU;

namespace Com.GUI.LibraryManager.Controls.SubControl
{
    /// <summary>
    /// Interaction logic for ucAirCeilingLayer.xaml
    /// </summary>
    public partial class ucAirCeilingLayer : UserControl
    {
        bool display = true;
        public ucAirCeilingLayer()
        {
            InitializeComponent();
        }
       
        private void Grid_Loaded(object sender, RoutedEventArgs e)
        {
            loadData();
        }
        public void loadData()
        {
            cbxCeilingLayer.ItemsSource = LibraryManagerInCom.CeilingLayerList;
           
            cbxCeilingLayer.DisplayMemberPath = "layer_type";
            cbxCeilingLayer.SelectedIndex = 0;
          
        }

        public void reloadData()
        {
            cbxCeilingLayer.ItemsSource = null;
            cbxCeilingLayer.Items.Clear();
            foreach (tb_ceiling_layer i in LibraryManagerInCom.CeilingLayerList)
            {
                cbxCeilingLayer.Items.Add(i);
            }
            cbxCeilingLayer.DisplayMemberPath = "layer_type";
            cbxCeilingLayer.SelectedIndex = 0;
          
        }

        private void cbxpecifictHeat_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                if (display)
                {
                    tb_ceiling_layer cl = (tb_ceiling_layer)cbxCeilingLayer.SelectedItem;
                   // txtId.Text = cl.id.ToString();
                }
            }
            catch (Exception)
            {
                
                throw;
            }
           
            
        }
        public void addNew()
        {
            display = false;
            txtId.Text = (LibraryManagerInCom.CeilingLayerList.Count() + 1).ToString() ;
            cbxCeilingLayer.Text = "";

        }
        public void saveData()
        {
            tb_ceiling_layer clt = new tb_ceiling_layer();
            clt.layer_type = cbxCeilingLayer.Text;
            LibraryManagerInCom.addCeilingLayer(clt);
            reloadData();
           
        }

        public void delData()
        {
            tb_ceiling_layer clt = (tb_ceiling_layer)cbxCeilingLayer.SelectedItem;
            LibraryManagerInCom.delCeilingLayer(clt);
            reloadData();
        }
        public void copyData()
        {
            tb_ceiling_layer clt = (tb_ceiling_layer)cbxCeilingLayer.SelectedItem;
            tb_ceiling_layer clt2 = LibraryManagerInCom.copyCeilingLayer(clt);
            cbxCeilingLayer.Text = clt2.layer_type;
            txtId.Text = (LibraryManagerInCom.CeilingLayerList.Count() + 1).ToString();
        }
    }
}
